<?php

	class WS_GlobalCon {
		
		private $DBADMIN;
		private $HASHID;
		
		public function __construct() {

			$this->DBADMIN 	= new WS_GlobalMod();
			$this->HASHID 	= sha1(time());

		}
		
		public function getPageAccess($strAccess, $strPage) {

			return $this->DBADMIN->getPageAccess($strAccess, $strPage);
			
		}
		
		public function getGradeIfPercent($strGrades) {

			$strArray = array('1.0', '1', '1.25', '1.50', '1.5', '1.75', '2.0', '2', '2.25', '2.50', '2.5', '2.75', '3.0', '3', '4.0', '4', '5.0', '5');

			return (in_array($strGrades, $strArray)) ? true : false;
			
		}
		
		# GET Log ID
		public function globalLogID() {

			return $this->getIDFromCookie($_SESSION['WB_UserID'], $_COOKIE['WB_Cookie']);
			
		}
		
		# GET ID FROM COOKIE
		public function getIDFromCookie($strSession, $strCookie) {

			if ( !empty($strCookie) ) {
				$strExplode = explode('-', $strCookie);
				return $strExplode['0'];
			}
			
			return $strSession;
		
		}
		
		public function getPictureName($strID) {

			return $this->DBADMIN->getPictureName($strID);
			
		}
		
		public function getStudentPictureName($strID) {

			return $this->DBADMIN->getStudentPictureName($strID);
			
		}
		
		public function getStudentCourse($strID) {

			return $this->DBADMIN->getStudentCourse($strID);
			
		}
		
		public function getStudentSection($strID = '', $strSemLinkerID = '', $strYearID = '') {

			return $this->DBADMIN->getStudentSection($strID, $strSemLinkerID, $strYearID);
			
		}
		
		public function getActiveYear_ORIGINAL() {
			
			$strDate = date("Y-m-d");
			
			$fyr = date('Y', strtotime($strDate));
			$m   = date('m', strtotime($strDate));
			
			if ( $m >= 6 && $m <= 10 ) {
				$tyr = date("Y", strtotime(date("Y")));
			}
			else {
				$tyr = date("Y", strtotime("+5 month", strtotime(date("Y"))));
			}
			
			$getActiveYearIfEmty = $this->DBADMIN->getActiveYearIfEmty();
			
			if ( $getActiveYearIfEmty['count'] == 0 ) {
				$this->DBADMIN->insertActiveYear($fyr, $tyr);
			}
			
			$return = $this->DBADMIN->getActiveYear($fyr, $tyr);
			
			return $return;
			
		}
		
		public function getActiveYear() {
			
			$fyr = date('Y');
			$tyr = date("Y", strtotime("+5 month", strtotime(date("Y"))));
			
			$getActiveYearIfEmty = $this->DBADMIN->getActiveYearIfEmty();
			
			if ( $getActiveYearIfEmty['count'] == 0 ) {
				$this->DBADMIN->insertActiveYear($fyr, $tyr);
			}
			
			$return = $this->DBADMIN->getActiveYearSemester();
			
			return $return;
			
		}
		
		public function activateNextSemesterSY($action = 'N') {
			
			$strDate = date("Y-m-d");
			
			$monthAdd = ( $action == 'Y' ) ? 2 : 5;
			$fyr = date('Y', strtotime($strDate));
			$tyr = date("Y", strtotime("+" . $monthAdd . " month", strtotime(date("Y"))));
			
			$this->DBADMIN->insertActiveYear($fyr, $tyr, $action);
			
		}
		
		public function bible($post) {
			$this->DBADMIN->bible($post);
		}
		
		
	}
?>